package com.bzframework.pro.io.entity;

import com.qcloud.cos.model.ciModel.persistence.ImageInfo;
import lombok.Getter;
import lombok.Setter;

import java.util.Map;

/**
 * @Author bingzhong
 * @Date 2024/12/9 11:51
 * @Description
 */
@Getter
@Setter
public class FileInfo {

    private String id;

    private String fileName;

    private String extension;

    private Integer length;

    private String md5;

    private String sha256;

    private String accessUrl;

    private Map<String, Object> others;

    private ImageInfo imageInfo;

    public FileInfo withBasePath(String apiBashPath) {
        if (!apiBashPath.endsWith("/")) {
            apiBashPath = apiBashPath + "/";
        }
        accessUrl = apiBashPath + "file/" + id + "." + extension + "?" + "accessKey=" + others.getOrDefault("accessKey", "");
        return this;
    }

}
